package com.clinic.service.impl;

import com.clinic.dao.ClinicUsersDao;
import com.clinic.entity.ClinicPerms;
import com.clinic.entity.ClinicRoles;
import com.clinic.entity.ClinicUsers;
import com.clinic.service.ClinicUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;


/**
 * (ClinicUsers)表服务实现类
 *
 * @author makejava
 * @since 2020-11-12 15:55:14
 */
@Service
public class ClinicUsersServiceImpl implements ClinicUsersService {

    @Autowired
    private ClinicUsersDao clinicUsersDao;
    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ClinicUsers> queryAllByLimit(int offset, int limit) {
        return this.clinicUsersDao.queryAllByLimit(offset, limit);
    }



    /**
     * 修改数据
     *
     * @param clinicUsers 实例对象
     * @return 实例对象
     */
    @Override
    public ClinicUsers update(ClinicUsers clinicUsers) {
        this.clinicUsersDao.update(clinicUsers);
        return this.queryById(clinicUsers.getCuid());
    }



    //新加方法
    @Override
    public List<ClinicUsers> getAllUsers() {
        return clinicUsersDao.getAllUsers();
    }

    @Override
    public List<ClinicRoles> getRolesByUsername(String user) {
        return clinicUsersDao.getRolesByUsername(user);
    }

    @Override
    public List<ClinicPerms> getPermissionByUsername(String user) {
        return clinicUsersDao.getPermissionByUsername(user);
    }

    @Override
    public ClinicUsers login(String username, String password) {
        return clinicUsersDao.login(username, password);
    }

    @Override
    public ClinicUsers queryById(Integer cuid) {
        return clinicUsersDao.queryById(cuid);
    }
    /**
     * 通过ID查询单条数据
     *
     * @param cuid 主键
     * @return 实例对象
     */
    /**
     * 新增数据
     *
     * @param clinicUsers 实例对象
     * @return 实例对象
     */
    @Override
    public ClinicUsers insert(ClinicUsers clinicUsers) {
        clinicUsersDao.insert(clinicUsers);
        return clinicUsers;
    }
}